// pages/user/recommend/reward/reward.js
import {salary} from '../../../../utils/base-data.js'
const config = getApp().globalData.config
const T = getApp().globalData.T
let token = ''
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    token = getApp().globalData.token;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getList();
  },

  getList() {
    T.req({
      loadTitle: '加载中...',
      url: config.api + 'recommendation/reward/list',
      method: 'GET',
      data: {
        token: token
      },
      success: (res) => {
        let list = res.list;
        if (list.length == 0) {
          return;
        }
        let _temArr = [];
        list.forEach((ele, i) => {
          _temArr.push({
            label_1: ele.redPacket ? true : false,
            label_2: !ele.employmentType ? true : false,
            label_3: !!ele.employmentType ? true : false,
            id: ele.positionId,
            workYear: ele.candidateRequire,
            name: ele.position,
            salary: salary[ele.salaryRange].title,
            type: 0,
            education: ele.education,
            company: ele.company,
            area: ele.street,
            status: 0,
            deadline: ele.deadline,
            reward: ele.reward
          })
        });
        this.setData({
          list: _temArr
        });
      }
    })
  }
})